package com.atguigu.srb.base.asserts;

import com.atguigu.srb.base.exception.BusinessException;
import com.atguigu.srb.base.response.ResponseEnum;

/**
 * 自定义断言类
 */
public class Asserts {
    //对参数进行校验，是否为空  是否相等 是否为true/false  不满足要求抛出自定义类型的异常
    //断言obj不为空：如果obj为空抛出异常
    public static void assertNotNull(Object obj , ResponseEnum responseEnum){
        if(obj==null){
            throw new BusinessException(responseEnum);
        }
    }
    public static void assertNotNull(String str , ResponseEnum responseEnum ){
        if(str==null || str.length()==0){
            throw new BusinessException(responseEnum);
        }
    }

    public static void assertNotTrue(boolean b, ResponseEnum responseEnum) {
        if(b){
            throw new BusinessException(responseEnum);
        }

    }
}
